trait Foo {
    fn method(&self) -> String;
}

impl Foo for u8 {
    fn method(&self) -> String {
        format!("u8: {}", *self)
    }
}

impl Foo for String {
    fn method(&self) -> String {
        format!("string: {}", *self)
    }
}

fn do_something<T: Foo>(x: T) -> String {
    x.method()
}

fn do_simplething(x: &dyn Foo) -> String {
    x.method()
}

fn main() {
    dbg!(std::mem::size_of::<&dyn Foo>());

    let x = 5u8;
    let y = "Hello".to_string();
    let z = "Hello again".to_string();

    println!("x:{:?}", do_something(x));
    println!("y:{:?}", do_something(y));
    println!("z simple:{:?}", do_simplething(&z));
}
